#!/usr/bin/perl

use CGI;
use File::Tail;

print "Content-type: text/html\n\n";

$| = 1; #set auto flush on

# param for specifying number of lines to tail.
$n =  CGI::param('n');
$file_name = CGI::param('file');

#show 100 lines by default
$tail = $n?$n:100;

# specifying default as of now
$file_name = $file_name?$file_name:"/var/log/httpd/access_log";

# tail -n <tail_lines>. Start with tail_lines
$tail_lines=10;

$tail_file=File::Tail->new(name=>$file_name,
                            maxinterval=>30,
                            adjustafter=>5,
                            maxbuf=>16384,
							tail=>$tail_lines);


while (defined($readline=$tail_file->read))
{
    print $readline."</br>";
}

